import Vue from 'vue'
import Router from 'vue-router'

const _import = require('./_import_' + process.env.NODE_ENV)
Vue.use(Router)

export const constantRouterMap = [
  { path: '/login', name: 'LoginPage', component: _import('auth/Login/Index'), hidden: true },
  { path: '/404', name: 'Error404', component: _import('error/404'), hidden: true },
  { path: '/401', name: 'Error401', component: _import('error/401'), hidden: true }
]

export const asyncRouterMap = [
  {
    path: '/',
    name: 'Index',
    component: _import('layout/Container'),
    meta: {
      name_str: '主页',
      isTopNav: true,
      toUrl: true
    },
    redirect: '/project/manage/index',
    children: [
      {
        path: 'home',
        name: 'HomePage',
        component: _import('dashboard/Dashboard'),
        meta: {
          name_str: '主页'
        }
      }
    ]
  },
  {
    path: '/project',
    name: 'ProjectManager',
    component: _import('layout/Container'),
    meta: {
      name_str: '项目',
      isTopNav: true
    },
    redirect: '/project/manage/index',
    children: [
      {
        path: 'manage',
        component: _import('layout/Layout'),
        name: 'SettingManager',
        redirect:"/project",
        meta: {
          name_str: '项目管理',
          noDropdown: false
        },
        icon: 'icon-setting1',
        children: [
          {
            path: 'index',
            name: 'ProjectManageIndex',
            component: _import('project/todotask/Index'),
            meta: {
              name_str: '我的待办任务'
            }
          },
          {
            path: 'responsibility',
            name: 'ProjectResponsibilityIndex',
            component: _import('project/responsibility/Index'),
            meta: {
              name_str: '我负责的项目'
            }
          },
          {
            path: 'detail',
            name: 'ProjectDetail',
            component: _import('project/detail/Index'),
            meta: {
              name_str: '项目详情',
            },
            hidden:true
          },
          {
            path: 'add',
            name: 'AddProject',
            component: _import('project/dialog/AddProject/Index'),
            meta: {
              name_str: '新建项目'
            },
            hidden:true
          },{
            path: 'modify',
            name: 'ModifyProject',
            component: _import('project/dialog/ModifyProject/Index'),
            meta: {
              name_str: '编辑项目',
            },
            hidden:true
          },{
            path: 'view_plan/:projectId/:taskId',
            name: 'ViewProjectPlan',
            component: _import('project/dialog/construction/EditBuildPlan'),
            meta: {
              name_str: '制定进度计划',
            },
            hidden:true
          },
          {
            path: 'edit/plan/:projectId/:taskId',
            name: 'EditProjectPlan',
            component: _import('project/dialog/construction/Replan'),
            meta: {
              name_str: '调整进度计划',
            },
            hidden:true
          },
          {
            path: 'owner/check/plan/:projectId/:taskId',
            name: 'OwnerCheckProgressPlan',
            component: _import('project/dialog/owner/CheckProgressPlan'),
            meta: {
              name_str: '审查进度计划',
            },
            hidden:true
          },
          {
            path: 'owner/check/result/:projectId/:taskId',
            name: 'OwnerCheckProgressPlanResult',
            component: _import('project/dialog/owner/OwnerCheckPlan'),
            meta: {
              name_str: '按照计划检查结果',
            },
            hidden:true
          },
          {
            path: 'edit/check/plan/:projectId/:taskId',
            name: 'EditOwnerCheckPlan',
            component: _import('project/dialog/owner/EditCheckPlan'),
            meta: {
              name_str: '编制进度检查计划',
            },
            hidden:true
          },{
            path: 'view_check_plan',
            name: 'ViewOwnerCheckPlan',
            component: _import('project/dialog/owner/ViewCheckPlan'),
            meta: {
              name_str: '查看进度检查计划',
            },
            hidden:true
          },{
            path: 'view_project_detail',
            name: 'ViewProjectDetail',
            component: _import('project/detail/Index'),
            meta: {
              name_str: '查看项目详情',
            },
            hidden:true
          },{
            path: 'supervisor/check/progress/:projectId/:taskId',
            name: 'SupervisorCheckProgressPlan',
            component: _import('project/dialog/supervisor/CheckProgressPlan'),
            meta: {
              name_str: '查看项目详情'
            },
            hidden: true
          },
          {
            path: 'engineering/checkreview/plan/:projectId/:taskId',
            name: 'EngineeringCheckProgressPlan',
            component: _import('project/dialog/engineering/ReviewPlanAndProgress'),
            meta: {
              name_str: '审查进度检查计划',
            },
            hidden: true
          },
          {
            path: 'responsibility/checkreview/plan/:projectId/:taskId',
            name: 'ResponsibilityCheckProgressPlan',
            component: _import('project/dialog/responsibility/ReviewPlanAndProgress'),
            meta: {
              name_str: '审查进度检查计划',
            },
            hidden: true
          },
          {
            path: 'construction/analyze/plan/:projectId/:taskId',
            name: 'ConstructionAnalyze',
            component: _import('project/dialog/construction/DelayAnalyze'),
            meta: {
              name_str: '延误影响分析',
            },
            hidden: true
          },
          {
            path: 'supervisor/analyze/plan/:projectId/:taskId',
            name: 'SupervisorAnalyze',
            component: _import('project/dialog/supervisor/DelayAffect'),
            meta: {
              name_str: '延误影响分析'
            },
            hidden: true
          },
          {
            path: 'owner/analyze/plan/:projectId/:taskId',
            name: 'OwnerAnalyze',
            component: _import('project/dialog/owner/PcsOwnerSupervise'),
            meta: {
              name_str: '延误影响分析'
            },
            hidden: true
          },
          {
            path: 'supervisor/review/plan/:projectId/:taskId',
            name: 'SupervisorReviewPlan',
            component: _import('project/dialog/supervisor/CheckNewProgressPlan'),
            meta: {
              name_str: '监理审查新进度'
            },
            hidden: true
          },
          {
            path: 'owner/check/lastresult/:projectId/:taskId',
            name: 'OwnerCheckResult',
            component: _import('project/dialog/owner/OwnerCheckPracticable'),
            meta: {
              name_str: '业主落实情况'
            },
            hidden: true
          }
        ]
      },
      {
        path: 'audit',
        name: 'AuditManager',
        component: _import('layout/Layout'),
        icon: 'icon-permission',
        redirect: '/audit/index',
        meta: {
          name_str: '审批'
        },
        children: [
          {
            path: 'index',
            name: 'PermissionUser',
            meta: {
              name_str: '审批管理'
            },
            component: _import('dashboard/Dashboard'),
            icon: ''
          },
          {
            path: 'user/add',
            name: 'PermissionUserAdd',
            meta: {
              name_str: '添加管理员'
            },
            hidden: true
          },
          {
            path: 'user/:id',
            name: 'PermissionUserEdit',
            meta: {
              name_str: '编辑管理员'
            },
            icon: '',
            hidden: true
          },
          {
            path: 'role',
            name: 'PermissionRole',
            meta: {
              name_str: '角色管理'
            },
            icon: ''
          },
          {
            path: 'role/add',
            name: 'PermissionRoleAdd',
            meta: {
              name_str: '添加角色'
            },
            icon: ''
          },
          {
            path: 'role/:id',
            name: 'PermissionRoleEdit',
            meta: {
              name_str: '编辑角色'
            },
            hidden: true,
            icon: ''
          }
        ]
      },
      {
        path: 'performance',
        name: 'PerformanceManager',
        component: _import('layout/Layout'),
        icon: 'icon-permission',
        redirect: '/performance/index',
        meta: {
          name_str: '绩效'
        },
        children: [
          {
            path: 'index',
            name: 'PermissionUser',
            meta: {
              name_str: '审批管理'
            },
            component: _import('dashboard/Dashboard'),
            icon: ''
          },
          {
            path: 'user/add',
            name: 'PermissionUserAdd',
            meta: {
              name_str: '添加管理员'
            },
            hidden: true
          },
          {
            path: 'user/:id',
            name: 'PermissionUserEdit',
            meta: {
              name_str: '编辑管理员'
            },
            icon: '',
            hidden: true
          },
          {
            path: 'role',
            name: 'PermissionRole',
            meta: {
              name_str: '角色管理'
            },
            icon: ''
          },
          {
            path: 'role/add',
            name: 'PermissionRoleAdd',
            meta: {
              name_str: '添加角色'
            },
            icon: ''
          },
          {
            path: 'role/:id',
            name: 'PermissionRoleEdit',
            meta: {
              name_str: '编辑角色'
            },
            hidden: true,
            icon: ''
          }
        ]
      }
    ]
  },
  {
    path: '/flow',
    name: 'FlowManager',
    component: _import('layout/Container'),
    meta: {
      name_str: '流程',
      isTopNav: true,
      toUrl:true
    },
    redirect:'/flow/index',
    children: [
      {
        path: 'index',
        name: 'FlowPage',
        component: _import('dashboard/Dashboard'),
        meta: {
          name_str: '详情页'
        }
      }
    ]
  },
  {
    path: '/document',
    name: 'DocumentManager',
    component: _import('layout/Container'),
    meta: {
      name_str: '文档',
      isTopNav: true,
      toUrl:true
    },
    redirect:'/document/index',
    children: [
      {
        path: 'index',
        name: 'DocumentPage',
        component: _import('dashboard/Dashboard'),
        meta: {
          name_str: '详情页'
        }
      }
    ]
  }
]

export default new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
